<?php
/**
 * 示例控制器
 */
namespace app\ctrl;


use Grafika\Grafika;

class testCtrl extends \ppphp
{

    public $param = '';
    public function index()
    {
        dump('处理开始'. microtime(true));
        $bg = APP .'asset/bg.png';
        $header_remote = 'http://kphcdr.qiniudn.com/540.jpg?roundPic/radius/!50p';


        $card = APP . 'asset/card.jpg';

        $name1 = $this->handel($bg,$header_remote,true);
        $name2 = $this->handel($name1,$card);


        dump($name2);
        dump('处理结束'. microtime(true));

    }

    public function handel($bg,$image,$isRemote=true)
    {
        $name = PPPHP .'/storage/'.time().rand(1,999999).'.png';

        $editor = Grafika::createEditor();
        $editor->open($image1,$bg);


        if($isRemote) {
            file_put_contents($name,file_get_contents($image));
            $editor->open($image2,$name);
        } else {
            $editor->open($image2,$image);
        }

        $editor->blend($image1,$image2,'normal',1.0,'top-left',22,40);
        $editor->save($image1,$name);

        return $name;
    }

}